<?php 
/* P3(c)

******************************************************************************
                                                                                      
                         __                                                        
                        /__)                                                       
                       /__        P3 - moving Technologie            
                        __)                                                          
                        __)                                                          
                                                                                        
                                                                                        
       Copyright 2009 by p3.co.at                                                                                 
                                                                                        
       visit www.p3.co.at to get more Informations 
       about Teriko - Betriebsdatenerfassung                                                                                 
       - it's not allowed to change this scripts
       - it's not allowed to remove this copyright-tag

       -- you can download the complete license   
          under http://www.teriko.org

 (c) by Patrik Pfaffenbauer and P3 (http://www.p3.co.at)

 | Programname: P3.Teriko
 | Authtor: P3.Verein
 | Coder: Patrik Pfaffenbauer
 | Version: 0.1

 | Change Index
 |_____________________________________________
 |                                             |
 |4.3.2010 Erstellung | Patrik Pfaffenbauer    |
 |_____________________________________________|

******************************************************************************

P3(c) */

function ShortText($str,$maxstr,$erw)
{
	if(strlen($str) > $maxstr)
	{	
		$str1 = substr($str,0,$maxstr);
		$str2 = strrchr($str1," ");
		
		if($str2 == false)
		{
			$str2 = strrchr($str1,".");
		}
		$str = substr($str1,0,($maxstr-strlen($str2)+1)).$erw;
	}
	return $str;
} 

function ConvertDate($datum,$needle)
{
	//NOT WORLDWIDE CONVERT
  $tmp_datum = explode($needle,$datum);
  if($needle=="."){ $needle = "-"; }else{ $needle = "."; }
  return $tmp_datum[2].$needle.$tmp_datum[1].$needle.$tmp_datum[0];
}

function htmloutput($text) 
{
	return nl2br($text);
}

function GetObject($site)
{
	if($site == "")
		return new Home();
		
	include('./_tables.php');
	$res = $GLOBALS['db']->Query("SELECT * FROM ".$tblmodules. " WHERE name='".$site."'");
							
	if($GLOBALS['db']->NumRow($res))
	{
		if($site == "member")
		{
			return new Member();	
		}
		else if($site == "country")
		{
			return new Country();
		}
		else if($site == "language")
		{
			return new Language();
		}
		else if($site == "permission")
		{
			return new Permission();
		}
		else if($site == "holiday")
		{
			return new Holiday();
		}
		else if($site == "customer")
		{
			return new Customer();
		}
		else if($site == "project")
		{
			return new Project();
		}
		else if($site == "task")
		{
			return new Task();
		}
		else if($site == "online")
		{
			return new Online();
		}
		else if($site == "offline")
		{
			return new Offline();
		}
		else if($site == "system")
		{
			return new System();
		}
		else if($site == "help")
		{
			return new Help();
		}
		else if($site == "pause")
		{
			return new Pause();
		}
		else if($site == "homenews")
		{
			return new Homenews();
		}
		else if($site == "reportsystem")
		{
			return new ReportSystem();
		}
		else if($site == "test")
		{
			return new Test();
		}
		else if($site == "department")
		{
			return new Department();
		}
	}
	else
	{
		 return new Home();
	}
	
	return $content;
}
function Redirect($site)
{
	echo '<script type="text/javascript">
		Redirect("'.$site.'");
		</script>';
}

function Alert($message)
{
	echo '<script type="text/javascript">
		alert("'.$message.'");
		</script>';
}

function GetSmarty()
{
	$smarty = new Smarty;
	$smarty->compile_check = $GLOBALS['tpl-compile'];
	$smarty->debug = $GLOBALS['debug'];
	$smarty->register_function('GetLang', 'GetSmartyLanguage');
	
	return $smarty;
}

function GetTitle()
{
	$title = $GLOBALS['db']->GetValue("title");
	
	$obj = GetObject($_GET['s']);
	$title .= ' - '.$obj->title;
	
	return $title;
}
?>